"use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["packages_drag-and-drop_drag-and-drop_ts-packages_hydro-analytics_hydro-analytics_ts"],{46747:(e,t,r)=>{r.d(t,{d:()=>l});var a=r(31223),n=r(23125),o=r(96540);let l=(e,t,{leading:r=!1,maxWait:l,trailing:s=!0,onChangeBehavior:i="flush"}={})=>{let d=(0,a.M)(e),c=(0,o.useMemo)(()=>{let e=void 0===l?{leading:r,trailing:s}:{leading:r,trailing:s,maxWait:l};return(0,n.A)((...e)=>d.current(...e),t,e)},[d,t,r,l,s]);return(0,o.useEffect)(()=>()=>{c?.[i]()},[c,i]),c}},53419:(e,t,r)=>{let a;r.d(t,{BI:()=>v,Ti:()=>h,lA:()=>m,sX:()=>g});var n=r(70837),o=r(18679),l=r(82075),s=r(11083);let{getItem:i}=(0,l.A)("localStorage"),d="dimension_",c=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","scid"];try{let e=(0,n.O)("octolytics");delete e.baseContext,a=new o.s(e)}catch{}function u(e){let t=(0,n.O)("octolytics").baseContext||{};if(t)for(let[e,r]of(delete t.app_id,delete t.event_url,delete t.host,Object.entries(t)))e.startsWith(d)&&(t[e.replace(d,"")]=r,delete t[e]);let r=document.querySelector("meta[name=visitor-payload]");for(let[e,a]of(r&&Object.assign(t,JSON.parse(atob(r.content))),new URLSearchParams(window.location.search)))c.includes(e.toLowerCase())&&(t[e]=a);return t.staff=(0,s.X)().toString(),Object.assign(t,e)}function m(e){a?.sendPageView(u(e))}function g(){return document.head?.querySelector('meta[name="current-catalog-service"]')?.content}function v(e,t={}){let r=g(),n=r?{service:r}:{};for(let[e,r]of Object.entries(t))null!=r&&(n[e]=`${r}`);a&&(u(n),a.sendEvent(e||"unknown",u(n)))}function h(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,JSON.stringify(t)]))}},58615:(e,t,r)=>{r.d(t,{M:()=>d,s:()=>c});var a=r(50467),n=r(82075),o=r(96540);let l=(0,n.A)("localStorage"),s="local-storage-update",i=class UseLocalStorageUpdateEvent extends Event{constructor(e,t){super(s),(0,a._)(this,"storageKey",void 0),(0,a._)(this,"storageValue",void 0),this.storageKey=e,this.storageValue=t}};function d(e,t){let r=(0,o.useRef)(t);(0,o.useEffect)(()=>{r.current=t});let[a,n]=(0,o.useState)(()=>{let t=l.getItem(e);return t?JSON.parse(t):r.current}),d=(0,o.useCallback)(t=>{n(t??r.current),void 0===t?l.removeItem(e):l.setItem(e,JSON.stringify(t)),document.dispatchEvent(new i(e,t))},[e]);return(0,o.useEffect)(()=>{function t(t){t.storageKey===e&&n(t.storageValue??r.current)}document.addEventListener(s,t);let a=l.getItem(e);return a?n(JSON.parse(a)):n(r.current),()=>{document.removeEventListener(s,t)}},[e]),[a,d]}function c(e){for(let t of e)l.removeItem(t),document.dispatchEvent(new i(t,void 0))}},69895:(e,t,r)=>{let a;r.d(t,{j:()=>d});var n=r(96540);function o(){return a||(a=window.matchMedia("(prefers-reduced-motion: reduce)"))}function l(){return!1}function s(){return o().matches}function i(e){let t=o();return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}}function d(){return(0,n.useSyncExternalStore)(i,s,l)}},87670:(e,t,r)=>{r.d(t,{Mp:()=>n.Mp,BS:()=>ey,Ux:()=>f,Hd:()=>n.Hd,vL:()=>n.vL,uN:()=>n.uN,cA:()=>n.cA,sH:()=>eb,AN:()=>n.AN,gB:()=>l.gB,IG:()=>n.IG,TT:()=>n.TT,Mk:()=>o.Mk,dU:()=>o.dU,FN:()=>o.FN,fF:()=>n.fF,E5:()=>n.E5,gY:()=>F,PM:()=>n.PM,zM:()=>n.zM,MS:()=>n.MS,FR:()=>n.FR,gl:()=>l.gl,_G:()=>l._G});var a=r(74848),n=r(48620),o=r(18831),l=r(43627),s=r(4559),i=r(71315),d=r(29731),c=r(54571),u=r(69895),m=r(58615),g=r(34164),v=r(96540),h=r(40961);let f=(0,v.createContext)(null);function p(e,t){let r=(0,v.useRef)(!1);(0,v.useEffect)(()=>(t?(document.body.classList.add(e),r.current=!0):(r.current&&document.body.classList.remove(e),r.current=!1),()=>{r.current&&document.body.classList.remove(e),r.current=!1}),[e,t])}let x=(0,v.createContext)(void 0);try{x.displayName||(x.displayName="RootElementContext")}catch{}var b=r(70170);let y={instructions:e=>`Moving ${e}.`,firstItemInList:"First item in list.",lastItemInList:"Last item in list.",movedBetween:(e,t)=>`Between ${e} and ${t}.`,movePosition:"Move item one position",cancelDrag:"Cancel drag mode",endDrag:"Place item",cancelMove:e=>`Cancel moving ${e}`,cancelMoveMultiple:(e,t)=>`Cancel moving ${e} and ${t} other items`,successfulFirstMove:e=>`${e} successfully moved to first item in list.`,successfulLastMove:e=>`${e} successfully moved to last item in list.`,successfulMove:(e,t,r)=>`${e} successfully moved between ${t} and ${r}.`,successfulNoMove:e=>`${e} did not move.`,entryLessThanOne:"Entry must be greater than 0.",entryGreaterThanList:e=>`Entry must be less than or equal to ${e}.`,entryIsRequired:"Entry is required.",entryIsInvalid:"Entry is invalid."},j={itemWillNotBeMoved:e=>`${e} will not be moved.`,movedToFirst:e=>`${e} will be first item in the list.`,movedToLast:e=>`${e} will be last item in the list.`,movedBetween:(e,t,r)=>`${e} will be between ${t} and ${r}.`},D={BEFORE:"Move item before",AFTER:"Move item after",ROW:"Move to position"},M=()=>"",N=(0,b.s)(e=>{(0,s.i)(e,{assertive:!0})},100),S={onDragStart:M,onDragOver:M,onDragMove:M,onDragEnd:M,onDragCancel:M};function I({equalMessage:e,firstPositionMessage:t,lastPositionMessage:r,betweenBeforeMessage:a,betweenAfterMessage:n,newIndex:o,currentIndex:l,items:s,moveAction:i}){if(o===l)return e;if(0===o&&i!==D.AFTER)return t;if(o===s.length-1&&i!==D.BEFORE)return r;switch(i){case D.BEFORE:return a;case D.AFTER:return n;case D.ROW:if(o{let{code:n}=e.nativeEvent;if(t.start.includes(n)){let t=a.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),r?.({event:e.nativeEvent}),!0)}return!1}},{eventName:"onClick",handler:(e,{onActivation:t})=>{e.preventDefault();let r=new KeyboardEvent("keydown",{key:"Enter",code:"Enter"});return t?.({event:r}),!0}}]);let _=({collisionRect:e,droppableRects:t,droppableContainers:r})=>{let a=(e.top+e.bottom)/2,n=[];for(let e of r){let{id:r}=e,o=t.get(r);if(o){let t=Math.abs(a-(o.top+o.bottom)/2);n.push({id:r,data:{droppableContainer:e,value:t}})}}return n.sort((e,t)=>e.data.value-t.data.value)},w={isKeyboardDragging:"DragAndDropContainer-module__isKeyboardDragging--sqA9I",container:"DragAndDropContainer-module__container--WugRR"};var E=r(46747),T=r(96296);let F=()=>{let e=(0,v.useContext)(f);if(!e)throw Error("useDragAndDrop can only be accessed from a DragAndDropContext.Provider component");let{overId:t,dragIndex:r,moveToPosition:a,items:n,direction:o,moveDialogItem:l,openMoveDialog:s,isInDragMode:i}=e;return{isDropTarget:(0,v.useCallback)(e=>t===e||null,[t]),isBefore:e=>null!==r&&e{}});function U(e){let{formProps:t,setIsInvalidOption:r,setHelperText:n,helperTextId:o}=e,{actions:l,onActionChange:s,actionsLabel:i}=t,[d,c]=(0,v.useState)(l[0]?.value),u=(0,v.useCallback)(e=>{s?.(e);let t=l.find(t=>t.value===e.target.value);t&&c(t.value)},[l,s]);return(0,a.jsx)(z.Provider,{value:(0,v.useMemo)(()=>({formLabel:d??"",onChange:(e,t)=>{n(e),r(t)},helperTextId:o}),[d,n,o,r]),children:(0,a.jsxs)("div",{className:(0,g.$)(H.form),children:[l.length>1&&(0,a.jsxs)(O.A,{required:!0,children:[(0,a.jsx)(O.A.Label,{children:i??"Action"}),(0,a.jsx)(T.A,{block:!0,onChange:u,children:l.map(e=>(0,a.jsx)(T.A.Option,{value:e.value,children:e.value},e.value))})]}),l.find(e=>e.value===d)?.renderInput]})})}let V=v.forwardRef((e,t)=>{let{helperText:r,isInvalid:n,...o}=e,{formLabel:l,onChange:s,helperTextId:i}=(0,v.useContext)(z);return(0,v.useEffect)(()=>{s(r??"",!!n)},[r,n,s]),(0,a.jsxs)(O.A,{required:!0,children:[(0,a.jsx)(O.A.Label,{children:l}),(0,a.jsx)(T.A,{block:!0,"aria-invalid":n,validationStatus:n?"error":void 0,"aria-describedby":i,ref:t,...o})]})});V.displayName="MoveDialogForm.SingleSelect";let W=v.forwardRef((e,t)=>{let{isInvalid:r,helperText:n,...o}=e,{formLabel:l,onChange:s,helperTextId:i}=(0,v.useContext)(z);return(0,v.useEffect)(()=>{s(n,!!r)},[n,r,s]),(0,a.jsxs)(O.A,{required:!0,children:[(0,a.jsx)(O.A.Label,{children:l}),(0,a.jsx)(q.A,{block:!0,"aria-invalid":r,validationStatus:r?"error":void 0,"aria-describedby":i,ref:t,...o})]})});function X(e){let{isInvalid:t,helperText:r,...n}=e,{formLabel:o,onChange:l}=(0,v.useContext)(z);(0,v.useEffect)(()=>{l(r,!!t)},[r,t,l]);let s={...n,renderAnchor:e=>{let{children:t,...r}=e;return(0,a.jsx)(R.Q,{trailingAction:k.TriangleDownIcon,block:!0,...r,children:t})}};return(0,a.jsxs)(O.A,{required:!0,children:[(0,a.jsx)(O.A.Label,{children:o}),(0,a.jsx)(L.X,{...s})]})}function Q(e){let{isInvalid:t,helperText:r,...n}=e,{formLabel:o,onChange:l,helperTextId:s}=(0,v.useContext)(z),i={anchor:"button",anchorClassName:H.datePickerAnchor,compressedHeader:!1,confirmation:!1,confirmUnsavedClose:!0,dateFormat:"long",placeholder:o,showTodayButton:!0,showClearButton:!1,variant:"single",weekStartsOn:"Sunday"};(0,v.useEffect)(()=>{l(r,!!t)},[r,t,l]);let d={...i,...n};return(0,a.jsxs)(O.A,{required:!0,children:[(0,a.jsx)(O.A.Label,{children:o}),(0,a.jsx)(G.DatePicker,{...d,"aria-describedby":s,fieldName:o})]})}W.displayName="MoveDialogForm.Text",U.SingleSelect=V,U.Text=W,U.MultiSelect=X,U.Date=Q,U.SingleSelectOption=T.A.Option;try{U.displayName||(U.displayName="MoveDialogForm")}catch{}try{X.displayName||(X.displayName="MultiSelect")}catch{}try{Q.displayName||(Q.displayName="DateInput")}catch{}let J="move-dialog-title",Y=({closeDialog:e,onSubmit:t,formProps:r,title:n,submitButtonLabel:o,returnFocusRef:l,...i})=>{let c,u,[m,h]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),x="";i.multiSelectItems?c=i.selectPanelProps.selected[0]:x=i.selectedItem.value;let[b,j]=(0,v.useState)(""),D=(0,v.useId)(),M=(0,v.useRef)(null);(0,$.g)({containerRef:M,onClickOutside:e=>e.preventDefault()});let N=async e=>{if(e.preventDefault(),m){let e=M.current?.querySelector('[aria-invalid="true"]');e&&e.focus();return}await t?.(e)};return i.multiSelectItems&&(u={...i.selectPanelProps,selected:i.selectPanelProps.selected,onSelectedChange:e=>{i.multiSelectItems&&(e[0]!==c?p(!0):i.selectPanelProps.onSelectedChange?.(e))},renderAnchor:e=>{let{children:t,...r}=e;return(0,a.jsx)(R.Q,{trailingAction:k.TriangleDownIcon,block:!0,...r,children:t})}}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B.l,{title:(0,a.jsx)("span",{className:(0,g.$)(K.title),id:J,...(0,d.G)(J),children:n??(i.multiSelectItems?"Move selected items":"Move selected item")}),onClose:()=>{if(e(),i.multiSelectItems){let e=i.selectPanelProps.selected;(0,s.i)(y.cancelMoveMultiple(e[0]?.text??"",e?.length??0),{assertive:!0})}else(0,s.i)(y.cancelMove(x),{assertive:!0})},width:"large",ref:M,renderBody:()=>(0,a.jsxs)("form",{onSubmit:N,...(0,d.G)("move-dialog-form"),onBlur:e=>e.stopPropagation(),className:(0,g.$)(K.form),noValidate:!0,"aria-labelledby":J,children:[(0,a.jsxs)(B.l.Body,{className:(0,g.$)(K.dialogBody),children:[(0,a.jsx)("div",{className:(0,g.$)(K.dialogTitle),children:i.multiSelectItems?(0,a.jsxs)(O.A,{required:!0,children:[(0,a.jsx)(O.A.Label,{requiredIndicator:!1,children:"Item(s)"}),(0,a.jsx)(L.X,{...u})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-bold pb-1",children:"Item"}),(0,a.jsx)("span",{children:x})]})}),(0,a.jsx)(U,{formProps:r,setHelperText:j,setIsInvalidOption:h,helperTextId:D}),(0,a.jsxs)(P.A,{"aria-live":"assertive",variant:m?"danger":"default",id:D,...(0,d.G)("drag-and-drop-move-dialog-flash"),children:[m?(0,a.jsx)(k.AlertIcon,{}):(0,a.jsx)(k.InfoIcon,{}),b]})]}),(0,a.jsx)(B.l.Footer,{className:"p-2",children:(0,a.jsx)(R.Q,{type:"submit",variant:"primary",...(0,d.G)("drag-and-drop-move-dialog-move-item-button"),children:o??"Move"})})]}),returnFocusRef:l}),f&&(0,a.jsxs)(B.l,{width:"large",title:"Missing selection",onClose:()=>{i.multiSelectItems&&p(!1)},children:[(0,a.jsx)(B.l.Body,{className:(0,g.$)(K.dialogBody),children:"The first item you selected cannot be deselected when performing a move."}),(0,a.jsx)(B.l.Footer,{className:"p-2",children:(0,a.jsx)(R.Q,{type:"submit",variant:"primary",onClick:()=>{i.multiSelectItems&&p(!1)},children:"I understand"})})]})]})};try{Y.displayName||(Y.displayName="MoveDialog")}catch{}let Z=(e,t)=>e!==t+1&&e!==t,ee=(e,t)=>e!==t-1&&e!==t,et=(e,t)=>void 0===t||t<0||t>=e.length||isNaN(t),er=({closeDialog:e,dialogTitle:t,returnFocusRef:r})=>{let n=(0,v.useRef)(null),{moveDialogItem:o,moveToPosition:l,items:i}=F(),{title:c,index:u}=o??{title:"",index:-1},[m,g]=(0,v.useState)(!1),[h,f]=(0,v.useState)(),[p,x]=(0,v.useState)(i.some((e,t)=>Z(t,u))?D.BEFORE:i.some((e,t)=>ee(t,u))?D.AFTER:D.ROW),[b,M]=(0,v.useState)(""),N=(0,v.useMemo)(()=>e=>{let t="";if(void 0===e||et(i,e))t=((e,t)=>void 0===t?y.entryIsRequired:t<0?y.entryLessThanOne:t>e.length?y.entryGreaterThanList(e.length):y.entryIsInvalid)(i,e);else{let r=i[e-1]?.title,a=i[e+1]?.title;t=I({equalMessage:j.itemWillNotBeMoved(c),firstPositionMessage:j.movedToFirst(c),lastPositionMessage:j.movedToLast(c),betweenBeforeMessage:j.movedBetween(c,r,i[e]?.title),betweenAfterMessage:j.movedBetween(c,i[e]?.title,a),newIndex:e,currentIndex:u,items:i,moveAction:p})}M(t)},[c,u,p,i]),S=(0,E.d)(N,100);(0,v.useEffect)(()=>{if(n.current?.value){let e=p===D.ROW?-1:0,t=parseInt(n.current?.value,10)+e;f(isNaN(t)?void 0:t),S(isNaN(t)?void 0:t)}},[S,n,p]);let C=async()=>{if(void 0!==h){switch(p){case D.ROW:h>=u?await l(u,h,!1):await l(u,h,!0);break;case D.BEFORE:await l(u,h,!0);break;case D.AFTER:default:await l(u,h,!1)}e(),function({newIndex:e,items:t,title:r,...a}){let n=t[e-1]?.title,o=t[e+1]?.title,l=I({equalMessage:y.successfulNoMove(r),firstPositionMessage:y.successfulFirstMove(r),lastPositionMessage:y.successfulLastMove(r),betweenBeforeMessage:y.successfulMove(r,n,t[e]?.title),betweenAfterMessage:y.successfulMove(r,t[e]?.title,o),newIndex:e,items:t,...a});(0,s.i)(l,{assertive:!0})}({newIndex:h,currentIndex:u,items:i,title:c,moveAction:p})}},A=e=>{et(i,e)?g(!0):g(!1),f(e&&isNaN(e)?void 0:e),S(e)};return(0,a.jsx)(Y,{closeDialog:e,title:t,formProps:{actions:[...i.some((e,t)=>Z(t,u))?[{value:D.BEFORE,renderInput:(0,a.jsx)(U.SingleSelect,{ref:p===D.BEFORE?n:void 0,helperText:b,onChange:e=>{A(Number(e.currentTarget.value))},isInvalid:!1,...(0,d.G)("drag-and-drop-move-dialog-position-input"),children:i.map((e,t)=>{if(Z(t,u))return(0,a.jsx)(T.A.Option,{value:t.toString(),children:e.title},`${e.title}-${t+1}`)})})}]:[],...i.some((e,t)=>ee(t,u))?[{value:D.AFTER,renderInput:(0,a.jsx)(U.SingleSelect,{ref:p===D.AFTER?n:void 0,helperText:b,onChange:e=>{A(Number(e.currentTarget.value))},isInvalid:!1,...(0,d.G)("drag-and-drop-move-dialog-position-input"),children:i.map((e,t)=>{if(ee(t,u))return(0,a.jsx)(T.A.Option,{value:t.toString(),children:e.title},`${e.title}-${t+1}`)})})}]:[],{value:D.ROW,renderInput:(0,a.jsx)(U.Text,{ref:p===D.ROW?n:void 0,helperText:b,min:1,max:i.length,defaultValue:u+1,type:"number",onChange:e=>{A(e.currentTarget.value?parseInt(e.currentTarget.value,10)-1:void 0)},isInvalid:m,...(0,d.G)("drag-and-drop-move-dialog-position-input")})}],onActionChange:e=>{x(e.target.value),g(!1)}},selectedItem:{value:c},onSubmit:C,returnFocusRef:r})};try{er.displayName||(er.displayName="DragAndDropMoveDialog")}catch{}var ea=r(46720),en=r(29255);let eo={instructionContainer:"KeyboardSpecificInstructionsDialog-module__instructionContainer--Heahc",instruction:"KeyboardSpecificInstructionsDialog-module__instruction--Bn8V2",footerContainer:"KeyboardSpecificInstructionsDialog-module__footerContainer--dKeqT",footerForm:"KeyboardSpecificInstructionsDialog-module__footerForm--eqNzz",footerButton:"KeyboardSpecificInstructionsDialog-module__footerButton--KEhPP"},el="hideKeyboardSpecificInstructions",es=({onClose:e})=>{let[t,r]=(0,m.M)(el,!1);return(0,a.jsxs)("div",{className:(0,g.$)(eo.footerContainer),children:[(0,a.jsx)("div",{className:(0,g.$)(eo.footerForm),children:(0,a.jsxs)(O.A,{children:[(0,a.jsx)(ea.A,{checked:t,onChange:()=>r(!t)}),(0,a.jsx)(O.A.Label,{children:"Don't show this again"})]})}),(0,a.jsx)("div",{className:(0,g.$)(eo.footerButton),children:(0,a.jsx)(R.Q,{onClick:e,children:"Close"})})]})},ei=({isOpen:e,onClose:t,direction:r,keyboardCodes:n=A})=>e?(0,a.jsx)("div",{onKeyDown:e=>{e.stopPropagation(),"Escape"===e.code&&t()},children:(0,a.jsx)(B.l,{title:"How to move objects via keyboard",subtitle:"This navigation is only available when move mode is activated.",onClose:t,renderFooter:()=>(0,a.jsx)(B.l.Footer,{className:"d-flex",children:(0,a.jsx)(es,{onClose:t})}),children:(0,a.jsxs)("table",{className:(0,g.$)(eo.instructionContainer),children:[(0,a.jsx)("thead",{className:"sr-only",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"text=bold",children:"Action"}),(0,a.jsx)("th",{className:"text=bold",children:"Keyboard Shortcut"})]})}),(0,a.jsxs)("tbody",{children:[(0,a.jsxs)("tr",{className:(0,g.$)(eo.instruction),children:[(0,a.jsx)("td",{children:y.cancelDrag}),(0,a.jsx)("td",{children:n.cancel.map((e,t)=>(0,a.jsxs)(v.Fragment,{children:[t>0&&(0,a.jsx)("span",{children:" / "}),(0,a.jsx)(en.U,{keys:e})]},e))})]}),(0,a.jsxs)("tr",{className:(0,g.$)(eo.instruction),children:[(0,a.jsx)("td",{children:y.movePosition}),(0,a.jsxs)("td",{children:[(0,a.jsx)(en.U,{keys:"vertical"===r?"up":"left"}),(0,a.jsx)("span",{children:" / "}),(0,a.jsx)(en.U,{keys:"vertical"===r?"down":"right"})]})]}),(0,a.jsxs)("tr",{className:(0,g.$)(eo.instruction,"border-bottom-0"),children:[(0,a.jsx)("td",{children:y.endDrag}),(0,a.jsx)("td",{children:n.end.map((e,t)=>(0,a.jsxs)(v.Fragment,{children:[t>0&&(0,a.jsx)("span",{children:" / "}),(0,a.jsx)("kbd",{className:"bgColor-default box-shadow-none fgColor-muted",children:e.toLowerCase()})]},e))})]})]})]})})}):null;try{es.displayName||(es.displayName="KeyboardSpecificInstructionsFooter")}catch{}try{ei.displayName||(ei.displayName="KeyboardSpecificInstructionsDialog")}catch{}let ed=({onDrop:e,items:t,direction:r="vertical",children:b,as:j="ul",renderOverlay:D,keyboardCodes:M,enableTouch:I=!1,...C},A)=>{let[E,T]=(0,v.useState)(!1),[F,k]=(0,v.useState)(0),[$,R]=(0,v.useState)(!1),[O,L]=(0,v.useState)(0),[P,B]=(0,v.useState)(null),[K,G]=(0,v.useState)(!1),[q]=(0,m.M)(el,!1),[H,z]=(0,v.useState)(!1),[U,V]=(0,v.useState)(null),W=t.map(e=>e.id),X=(0,v.useMemo)(()=>t.reduce((e,t)=>(e[t.id]=t.title,e),{}),[t]);p("is-dragging",E),p(w.isKeyboardDragging??"",H);let[Q,J]=(0,v.useState)(null),Y=(0,u.j)(),Z=(0,v.useCallback)(()=>{G(!1)},[]),ee=(0,v.useCallback)(e=>{if(!e.active)return;(0,s.i)(y.instructions(X[e.active.id]??e.active.id),{assertive:!0});let t=e.active.data.current?.metadata;B(t?.id??null),L(e.active.data.current?.sortable.index??0),k(e.active.data.current?.sortable.index??0),T(!0)},[X]),et=(0,v.useCallback)(e=>{let t=e.over?.data.current?.metadata;B(t?.id??null),$||R(!0),e.over&&e.over.data.current&&k(e.over.data.current.sortable.index)},[$]);(0,v.useEffect)(()=>{if(E&&$)if(0===F)N(y.firstItemInList);else if(F===W.length-1)N(y.lastItemInList);else{let e=F<=O,t=F===O,r=e?W[F-1]:W[F+1],a=t?W[F+1]:W[F];N(y.movedBetween(X[r],X[a]))}},[E,$,F,X,W,O]);let ea=(0,v.useCallback)(e=>{(0,s.i)(`${X[e.active.id]??e.active.id} not moved.`,{assertive:!0}),T(!1),z(!1),R(!1),setTimeout(()=>{document.activeElement?.scrollIntoView({behavior:Y?"instant":"smooth",block:"nearest"})},1)},[X,Y]),en=(0,v.useCallback)(r=>{if(T(!1),z(!1),R(!1),!r.active||!r.over)return;let a=r.active.data.current?.metadata,n=r.over.data.current?.metadata;a?.id!==n?.id&&e({dragMetadata:a,dropMetadata:n,isBefore:Fe.id);if(e===t)(0,s.i)(y.successfulNoMove(a),{assertive:!0});else if(0===e)(0,s.i)(y.successfulFirstMove(a),{assertive:!0});else if(e===r.length-1)(0,s.i)(y.successfulLastMove(a),{assertive:!0});else{let o=e<=t?n[e-1]:n[e+1],l=n[e],i=r.find(e=>e.id===o)?.title??"",d=r.find(e=>e.id===l)?.title??"";(0,s.i)(y.successfulMove(a,i,d),{assertive:!0})}}({newIndex:F,currentIndex:O,items:t,title:X[r.active.id]})},[F,O,t,X,e]),eo=(0,v.useCallback)((t,r,a)=>{B(W[r]??null);let n=W[t],o=W[r];n&&o&&e({dragMetadata:{id:n},dropMetadata:{id:o},isBefore:a??r()=>{$||q||G(!0),z(!0)},[q,$]),ec=(0,v.useCallback)((e,t,r)=>{V({title:e,index:t,returnFocusRef:r})},[]),eu=(0,v.useCallback)(()=>{V(null),J(U?.returnFocusRef?.current??null)},[U]),em=(0,n.MS)(n.IG),eg=(0,n.MS)(n.cA),ev=(0,n.MS)(CustomKeyboardSensor,{coordinateGetter:l.JR,keyboardCodes:M,onActivation:ed}),eh=(0,v.useMemo)(()=>I?[eg,em,ev]:[eg,ev],[I,eg,em,ev]),ef=(0,n.FR)(...eh);(0,v.useEffect)(()=>{Q?.focus(),J(null)},[Q]);let ep=t[O],[ex]=(0,c.I)(()=>document.body,null,[i.XC?.body]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ei,{isOpen:K,onClose:Z,direction:r,keyboardCodes:M}),(0,a.jsx)(n.Mp,{collisionDetection:(0,v.useMemo)(()=>"horizontal"===r?n.y$:_,[r]),modifiers:(0,v.useMemo)(()=>"horizontal"===r?[o.dU]:[o.FN],[r]),sensors:ef,onDragStart:ee,onDragOver:et,onDragEnd:en,onDragCancel:ea,accessibility:(0,v.useMemo)(()=>({container:es,announcements:S}),[es]),children:(0,a.jsx)(l.gB,{items:W,strategy:(0,v.useMemo)(()=>"horizontal"===r?l.m$:l._G,[r]),children:(0,a.jsxs)(f.Provider,{value:(0,v.useMemo)(()=>({overId:P,dragIndex:O,moveToPosition:eo,items:t,direction:r,openMoveDialog:ec,moveDialogItem:U,isInDragMode:E&&!K}),[P,O,eo,t,r,ec,U,E,K]),children:[U&&(0,a.jsx)(er,{closeDialog:eu}),(0,a.jsx)(j,{...C,ref:A,className:(0,g.$)(w.container,C.className),...(0,d.G)("sortable-list"),onKeyDown:e=>{E&&"Tab"===e.code&&e.preventDefault()},children:b}),ex?(0,h.createPortal)((0,a.jsx)(n.Hd,{dropAnimation:null,className:(0,g.$)(w.container),children:ep&&!K?D(ep,O):null}),ex):null]})})})]})},ec=(0,v.forwardRef)(ed);try{ed.displayName||(ed.displayName="DragAndDropContainer")}catch{}try{ec.displayName||(ec.displayName="DragAndDrop")}catch{}let eu=(0,v.createContext)({title:"",index:0,id:""}),em={dragItem:"DragAndDropItem-module__dragItem--rV0hu",vertical:"DragAndDropItem-module__vertical--jl9So",horizontal:"DragAndDropItem-module__horizontal--UHY1O",contents:"DragAndDropItem-module__contents--zC2eY",dragOverlay:"DragAndDropItem-module__dragOverlay--EAT8P"};var eg=r(21513),ev=r(26108);let eh=()=>{let e=(0,v.useContext)(eu);if(!e)throw Error("useDragAndDropItem must be used within a DragAndDropItemContextProvider");return e},ef={trigger:"DragAndDropTrigger-module__trigger--vk0HP",hideDragHandler:"DragAndDropTrigger-module__hideDragHandler--TSI5X",mouseTrigger:"DragAndDropTrigger-module__mouseTrigger--BI5oP",buttonTrigger:"DragAndDropTrigger-module__buttonTrigger--wP42o",touchEnabled:"DragAndDropTrigger-module__touchEnabled--_fwSu"},ep=(0,v.forwardRef)(function(e,t){let{title:r,id:n}=eh(),{setActivatorNodeRef:o,listeners:s,isDragging:i,items:c}=(0,l.gl)({id:n,data:{metadata:{id:n}}}),u=(0,v.useRef)(null);(0,eg.T)(t,u);let{onMouseDown:m,onClick:h,onKeyDown:f,onTouchStart:p}=s;return(0,a.jsxs)("div",{...(0,d.G)("sortable-trigger-container"),className:(0,g.$)(ef.trigger,1===c.length?ef.hideDragHandler:ef.touchEnabled),children:[(0,a.jsx)("div",{onMouseDown:m,onTouchStart:p,className:(0,g.$)(ef.mouseTrigger),...(0,d.G)("sortable-mouse-trigger")}),(0,a.jsx)(ev.K,{className:ef.buttonTrigger,"aria-label":`Move ${r}`,ref:e=>{u.current=e,o(e)},onKeyDown:f,onClick:h,variant:"invisible",role:i?"application":"button",icon:k.GrabberIcon,size:"large",...e,...(0,d.G)("sortable-trigger")})]})});try{ep.displayName||(ep.displayName="DragAndDropTrigger")}catch{}let ex=({children:e,id:t,index:r,title:n,containerStyle:o,style:s,hideTrigger:i,isDragOverlay:c=!1,role:m,as:h="li",itemClassName:f,elementId:p,...x})=>{let b=(0,u.j)(),{setNodeRef:y,isDragging:j,transform:D,transition:M}=(0,l.gl)({id:t,data:{metadata:{id:t}}}),{direction:N,isInDragMode:S}=F(),I=(0,g.$)("position-relative",x.className,S&&{[em.dragItem]:j,[em.horizontal]:"horizontal"===N,[em.vertical]:"vertical"===N}),C={transform:D?` translateX(${Math.round(D.x)}px) translateY(${Math.round(D.y)}px) scaleX(${D.scaleX}) scaleY(${D.scaleY}) `:"none",transition:b?"none":M};return(0,a.jsx)(eu.Provider,{value:(0,v.useMemo)(()=>({index:r,title:n,id:t}),[r,t,n]),children:(0,a.jsx)(c?"div":h,{...x,...(0,d.G)(c?"drag-overlay":"sortable-item"),className:I,style:{...c?{}:o,...C},ref:y,id:p,children:(0,a.jsxs)("div",{style:s,className:(0,g.$)("position-relative",f,S&&em.contents,c&&em.dragOverlay),role:m,children:[!i&&(0,a.jsx)(ep,{}),e]})})})};try{ex.displayName||(ex.displayName="DragAndDropItem")}catch{}let eb=v.forwardRef(({Component:e,returnFocusRef:t,...r},n)=>{let{title:o,index:l}=eh(),{items:s,openMoveDialog:i}=F(),d=(0,v.useCallback)(()=>{i(o,l,t??n)},[i,o,l,t,n]);return 1===s.length?null:(0,a.jsx)(e,{ref:n,...r,onClick:d,onSelect:d})});eb.displayName="MoveDialogTrigger";let ey=Object.assign(ec,{Item:ex,DragTrigger:ep,MoveDialog:Y,MoveDialogForm:U,MoveDialogTrigger:eb,DragAndDropMoveDialog:er});try{ey.displayName||(ey.displayName="DragAndDrop")}catch{}r(74979)}}]); //# sourceMappingURL=packages_drag-and-drop_drag-and-drop_ts-packages_hydro-analytics_hydro-analytics_ts-15c239de4e25.js.map